package com.example.ntier.model.test;

import java.sql.SQLException;
import java.util.List;

import oracle.net.aso.e;

import com.example.ntier.model.DbContext;
import com.example.ntier.model.dal.DepartmentDAL;
import com.example.ntier.model.dal.EmployeeDAL;
import com.example.ntier.model.entity.Department;
import com.example.ntier.model.entity.Employee;

public class Driver {

	public static void main(String[] args) throws SQLException {
		DbContext dbContext = DbContext.getInstance();
		List<Department> departments = dbContext.getDeparments().getAll();
		for (Department department : departments) {
			System.out.println(department);
		}
		System.out.println("-----------------------------------------");
		List<Employee> employees = dbContext.getEmployees().getAll();
		for (Employee employee : employees) {
			System.out.println(employee);
		}
		
		System.out.println("-----------------------------------------");
		
//		Employee employee = new Employee();
//		employee.setFirstName("Koray");
//		employee.setLastName("ALTINDAŞ");
//		employee.setDepartment(dbContext.getDeparments().findById(2));
//		boolean result = dbContext.getEmployees().insert(employee);
//		System.out.println(result);
		System.out.println("-----------------------------------------");
		System.out.println(dbContext.getEmployees().findById(4));
		
//		DepartmentDAL departmentDAL = new DepartmentDAL();
////		Department department = departmentDAL.findById(9);
////		department.setName("Rubby");
////		departmentDAL.update(department);
////		
////		Department department2 = departmentDAL.findById(9);
////		System.out.println(department2);
//		List<Department> departments = departmentDAL.getAll();
//		for (Department department : departments) {
//			System.out.println(department);
//		}
//		System.out.println("Total Count : " + departmentDAL.getCount());
		
//		DepartmentDAL departmentDAL = new DepartmentDAL();
//		
//		EmployeeDAL employeeDAL = new EmployeeDAL();
//		Employee employee = new Employee();
//		employee.setFirstName("Önder");
//		employee.setLastName("ŞAHİN");
//		employee.setDepartment(departmentDAL.findById(6));
//		boolean result = employeeDAL.insert(employee);
//		System.out.println(result);
		
		// DepartmentDAL departmentDAL = new DepartmentDAL();
		// EmployeeDAL employeeDAL = new EmployeeDAL(departmentDAL);
		
//		List<Employee> employees = employeeDAL.getAll();
//		for (Employee employee : employees) {
//			System.out.println(employee);
//		}
		
//		Employee employee = employeeDAL.findById(5);
//		Employee employee2 = employee.getManager();
//		employee2.getManager().getDepartment();
	}
}
